<?php

include 'connection.php';

if (is_array($_POST['id'])) {

   $id = join(',', $_POST['id']);//join把数组元素组合为一个字符串

} elseif (is_numeric($_GET['id'])) {

   $id = (int) $_GET['id'];

} else {
   echo '数据不合法';
   exit;
}

$sql = "delete from user where id in($id)";

$result = mysqli_query($conn, $sql);

if ($result) {
   echo '删除成功';
} else {
   echo '删除失败';
}
?>